# favourite_languages = {
#     'jen': 'python',
#     'sarah': 'c',
#     'edward': 'ruby',
#     'phil': 'python',
#     }

# language = favourite_languages['sarah'].title()
# print(f"Sarah's favourite language is {language}.")

# # for name, language in favourite_languages.items():
# #     print(f"{name.title()}'s favourite language is {language.title()}")

# for name in favourite_languages.keys():
#     print(name.title())

###################按特定顺序遍历字典中的列表###################

# for name in sorted(favourite_languages.keys()):
#     print(f"{name.title()}, thank you for taking the poll.")

###################遍历字典中的所有值###################

# print("The following languages have been mentioned:")
# # for language in favourite_languages.values():
# #     print(language.title())
# for language in set(favourite_languages.values()):
#     print(language.title())

###################在字典中存储列表###################

favourite_languages = {
    'jen': ['python', 'ruby'],
    'sarah': ['c'],
    'edward': ['ruby', 'go'],
    'phil': ['python', 'haskell'],
}

for name in favourite_languages.keys():
    if len(favourite_languages[name]) == 1:
        print(f"\n{name.title()}'s favourite language is:")
    else:
        print(f"\n{name.title()}'s favourite languages are:")
    for language in favourite_languages[name]:
        print(f"\t{language.title()}")
